package com.season.other.jackson;

import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.List;

public class JacksonTool {

    public static Object read(String jsonStr, Class<List> collectionClass, Class bean) throws IOException {
        
        ObjectMapper mapper = new ObjectMapper();
        JavaType javaType = mapper.getTypeFactory().constructParametricType(collectionClass, bean);
        //如果是Map类型  mapper.getTypeFactory().constructParametricType(HashMap.class,String.class, Bean.class);  
        Object o = mapper.readValue(jsonStr, javaType);
        return o;
    }
}
